-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Haskell checks on ci #5
Haskell checks on ci #5
Conversation
d8c00a5
to
62c2d29
Compare
We've decided not to do the check for cabal files in this PR (unless we find a solution quickly). |
2d31644
to
4a6e6d2
Compare
5a660a7
to
093f5a6
Compare
backend/default.nix
Outdated
); | ||
|
||
# Set a constant name for the src closure | ||
source = let |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIU this source
thing and the above ignoreFilter
are only used to run hlint
, I see it used only in hlint-html
(and btw, does ${source}
there refer to this source
or something else?). Is it indeed needed only for hlint
or is it implicitly used somewhere else? I just Ctrl-F'ed source
.
I have an alternative solution: just call hlint
from pipeline.yaml
using nix run
. Pros:
- No need to have all this extra code in this file (
source
,ignoreFilter
). Though maybe I am wrong and it's needed for something else as well. - Less steps involved, easier to understand what's going on, easier to find what arguments are passed and where to change them.
AFAIU there is one problem: we don't know how to make nix run
work with flakes. If that's the case and we don't figure it out quickly, I am okay with changing it later.
backend/default.nix
Outdated
library = project.edna.components.library; | ||
server = project.edna.components.exes.edna-server; | ||
test = project.edna.checks.edna-test; | ||
hlint-html = runCommand "hlint.html" {} "${hlint}/bin/hlint ${source} --no-exit-code --report=$out -j"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- What is
hlint.html
? Do you understand? - Why do we pass
--no-exit-code
? This way it seems very unlikely to notice when it reports anything. If we don't want CI to fail whenhlint
fails, we can mark the corresponding step as optional in the CI config. Just setsoft_fail: true
. I think it's better because this way it will be easier to notice thathlint
reported something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
It's the name of the output file generated in the closure for the
hlint-html
derivation. It's an arbitrary name. The important part is the closure itself and its hash, which depends on the inputs defined insource
. -
No idea. This looks like what Yegor wrote years ago for Disciplina. I suspect it has just been cargo culted ever since. Feel free to adjust the invocation of
hlint
as you see fit. Just make sure you put something in$out
somehow.
flake.nix
Outdated
backend-hlint = backend.hlint; | ||
}) nixpkgs.legacyPackages; | ||
|
||
pipelineFile = common-infra.mkPipelineFile self; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do, actually.
flake.nix
Outdated
let pkgs = nixpkgs.legacyPackages.${system}; | ||
in pkgs.mkShell { | ||
inputsFrom = [ packages.backend-lib ]; | ||
buildInputs = with pkgs.haskellPackages; [ cabal-install hpack ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't use dev shell and I am not sure anybody needs it, but if we decide to keep it, probably we don't need hpack
here because we don't use it (no package.yaml
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
devShell
is the Flake equivalent of shell.nix
-- and yes, I use it all the time.
flake.nix
Outdated
outputs = { self, nixpkgs, haskell-nix, hackage, stackage, common-infra }: | ||
let | ||
packagesFor = system: rec { | ||
pkgs = nixpkgs.legacyPackages.${system}.extend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the semantic of this pkgs
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flakes define derivations for all known systems. In the context of a flake, nixpkgs
isn't a set of packages. It's a set of sets of packages. So you need to use the set for the current (for some definition of "current") system.
flake.nix
Outdated
with packagesFor system; { | ||
backend-lib = backend.library; | ||
backend = backend.server // { | ||
meta.modulePath = [ "services" "edna" "backend" ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is meta.modulePath
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea. Removed it.
flake.nix
Outdated
}; | ||
}) nixpkgs.legacyPackages; | ||
|
||
ciSystems = [ "x86_64-linux" ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, it seems very unlikely that we will have more than one ciSystem
in any foreseeable future, so this file can be simplified, we don't need to iterate over systems and pass them to functions, we can have a single constant ciSystem
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't used anywhere. mkPipelineFile
only generates steps for x86_64-linux
.
flake.lock
Outdated
"type": "github" | ||
} | ||
}, | ||
"naersk": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/nmattia/naersk says "Nix support for building cargo crates". Do we need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used by deploy-rs
. flake.lock
contains all transitive dependencies for all inputs in the flake. deploy-rs
is a transitive dependency of common-infra
which is an input to this flake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIU we don't use deploy-rs
either, but I see that it's a dependency of common-infra
, so ok. It's a bit poor granularity (that we need to mention so many packages just for a small piece of common-infra
), but I guess we will end up using deploy-rs
anyway, so it's not a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
common-infra
has 2 nix functions: mkNode
to define deployment nodes, and mkPipelineFile
that generates CI steps which uses the former to generate deployment steps. So we're technically using half of common-infra
😛
Packages mentioned in flake.lock
don't necessarily end up in any of the closures, and since Nix is lazy, they don't even get evaluated unless you actually use them somewhere. The lockfile is eager and will contain all transitive locks regardless of whether they are used. It's just extra noise, that's all.
@mkaito I have a question to you.
So AFAIU P. S. Example with |
Ah, oh, sorry, it's not in I've just tested my hypotheses. First I tried to just do
Then I tried to also add I don't want to go further with experiments, will wait for Chris to respond. |
The command It relies on a flake concept called "apps", where you define executables in a flake output that can be run with What you're looking for is now called This will do what you want. $ nix shell nixpkgs#hlint -c hlint Note the Generally speaking, all our inputs should be declared in the flake, and everything should be run through the flake. The The files |
What do you mean by "build a separate CI step"? Does it generate |
Ok, let me test it in my branch. |
Yes.
By reading the {
"steps": [
{
"agents": [],
"command": "nix-build -A packages.x86_64-linux.backend-lib",
"label": "Build backend-lib"
},
{
"agents": [],
"command": "nix-build -A packages.x86_64-linux.backend-server",
"label": "Build backend-server"
},
{
"agents": [],
"command": "nix-build --no-out-link -A checks.x86_64-linux.backend-hlint",
"label": "backend-hlint"
},
{
"agents": [],
"command": "nix-build --no-out-link -A checks.x86_64-linux.backend-test",
"label": "backend-test"
},
"wait"
]
}
It doesn't. It just runs what you tell it to run. For example, {
hlint-html = runCommand "hlint.html" {} "${hlint}/bin/hlint ${source} --no-exit-code --report=$out -j";
} |
So does it replace
Yes, and I don't like that, don't understand why it's done this way and proposed to change that. I like
much more. |
I've cleaned up some things and removed pipeline generation. |
@mkaito thank you, that's exactly what I wanted to see. LGTM now. One last question I wanted to ask: I see the things in flake's output are called If I rename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with merging it given that:
- You fix CI so that it passes (obviously).
- Commits are cleaned up.
- @sashasashasasha151 reviews latest changes and confirms he's satisfied with them.
There are outputs that are treated specially.
The
Yeah, although flakes are sparsely documented. Half of what we know we learned by reading the C++ source code of Nix itself. The best documentation I've found is oddly enough The de-facto standard documentation is the old and closed RFC 49. There's a half decent wiki page too, and some tutorial style blog posts. The Nix folks keep pussyfooting about Flakes. Meanwhile, the rest of the Nix world has been using them a long time and are quite happy. They actually just moved the target for flake release from 3.0 to 3.5 for no apparent reason other than more bikeshedding. Never change, Nix. Never change...
Yes they will, because we don't use any flake specific features in the current pipeline. The shim in It becomes important once you use a Nix 3.0 client and want to use things like Some of the flakes I've written for various projects keep a pinned master build of Nix in the devShell so that we can run things like flake checks directly without a shim, but we haven't quite standardized on how exactly we want to do these things. |
91fbc0f
to
a2d7986
Compare
a2d7986
to
5585fc3
Compare
Description
Related issue(s)
https://issues.serokell.io/issue/EDNA-11
✅ Checklist for your Pull Request
Related changes (conditional)
Tests
silently reappearing again.
Documentation
Stylistic guide (mandatory)